using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using nDeveloper.Data;
using nDeveloper.BO.Base.Domain;

namespace Windows.Teste
{
    abstract public class BaseDb : IDisposable
    {
        protected BaseDataAccess con = new BaseDataAccess(DataBaseConfig.GetConnectionString(), RetornaProviderConfigurado(), true);
        protected static SqlConvert SQLConvert = new SqlConvert(RetornaProviderConfigurado());

        private static Providers RetornaProviderConfigurado()
        {
            Providers prov;
            if (DataBaseConfig.GetServerType() == nDeveloper.BO.Base.Constants.vsDataBase.SQLServer2000 | DataBaseConfig.GetServerType() == nDeveloper.BO.Base.Constants.vsDataBase.SQLServer2005)
            {
                prov = Providers.SqlServer;
            }
            else if (DataBaseConfig.GetServerType() == nDeveloper.BO.Base.Constants.vsDataBase.Oracle)
            {
                prov = Providers.Oracle;
            }
            else if (DataBaseConfig.GetServerType() == nDeveloper.BO.Base.Constants.vsDataBase.MySQL)
            {
                prov = Providers.MySql;
            }
            else if (DataBaseConfig.GetServerType() == nDeveloper.BO.Base.Constants.vsDataBase.Firebird)
            {
                prov = Providers.Firebird;
            }
            else if (DataBaseConfig.GetServerType() == nDeveloper.BO.Base.Constants.vsDataBase.PostgreSQL)
            {
                prov = Providers.PostgreSql;
            }
            else
            {
                prov = Providers.SqlServer;
            }
            return prov;
        }

        public virtual void Dispose()
        {
        }
    }
}
